﻿using System.Reflection.Emit;
using DataManageSystem.Models;
using Microsoft.EntityFrameworkCore;

namespace DataManageSystem.Data
{
    public class ApplicationDbContext : DbContext
    {
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured) // 确保只有在没有配置的情况下才手动配置
            {
                optionsBuilder.UseMySql("Server=localhost;Database=honey;User=root;Password=123456;",
                    ServerVersion.AutoDetect("Server=localhost;Database=honey;User=root;Password=123456;"));
            }
        }

        // 添加数据库表
        public DbSet<User> User { get; set; }
        public DbSet<Order> Orders { get; set; }
        public DbSet<Notice> Notice { get; set; }
        public DbSet<News> News { get; set; }
        public DbSet<Log> Logs { get; set; }
        public DbSet<MonitorDev> MonitorDevs { get; set; }
        public DbSet<ImportRecord> ImportRecords { get; set; }
        public DbSet<OfficeDevices> OfficeDevices { get; set; }
        public DbSet<OfficeDevCategory> OfficeDevCategories { get; set; }
        public DbSet<Script> Scripts { get; set; }
    }
}
